package com.xx.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xx.entity.Categories;
import com.xx.entity.CategoriesList;
import com.xx.mapper.CategoriesMapper;
import com.xx.service.ICategoriesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class CategoriesServiceImpl implements ICategoriesService {
    @Autowired
    CategoriesMapper categoriesMapper;

    @Override
    public Categories queryById(Integer categoryId) {
        return categoriesMapper.queryById(categoryId);
    }

    @Override
    public PageInfo<Categories> queryByPage(Categories categories, Integer pageNum) {
        PageHelper.startPage(pageNum,5);
        List<Categories> list = categoriesMapper.queryAllByLimit(categories);
        PageInfo<Categories> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int insert(Categories categories) {
        return categoriesMapper.insert(categories);
    }

    @Override
    public int update(Categories categories) {
        return categoriesMapper.update(categories);
    }

    @Override
    public int deleteById(Integer categoryId) {
        return categoriesMapper.deleteById(categoryId);
    }

    @Override
    public List<CategoriesList> list() {
        return categoriesMapper.list();
    }
}
